{% extends 'base_backend.html' %}
{% load static %}

{% block header_tail %}
    <link rel="stylesheet" href="{% static 'public/CodeMirror/lib/codemirror.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/theme/lesser-dark.css' %}">
    <link rel="stylesheet" href="{% static 'public/html5shiv/css/jquery.slinky.css' %}">
    <link rel="stylesheet" href="{% static 'plugins/iCheck/all.css' %}">
{% endblock header_tail %}

{% block section_content %}
    <div class="box-header with-border">
        <h3 class="box-title">URL查询</h3>
    </div>
    <div class="box box-primary">
        <div class="modal-content">
            <div class="box-header with-border">
                <form action="{% url 'task:reject' %}" method="post">{% csrf_token %}
                    <div class="col-md-8">
                        <div class="form-group" style="display: flex; flex-wrap: wrap; justify-content: start;">查询URL:
                            <a href="{{ url }}" target="_blank">{{ url }}&nbsp;&nbsp;</a>
                        </div>
                        {% if not info %}
                        <div class="form-group" style="display: flex; flex-wrap: wrap; justify-content: start;">
                            相关域名配置任务id：
                                {% for task in searchTasks %}
                                    <label>
                                      <input type="checkbox" name="searhtaskid" class="minimal" value="{{ task.id }}"><a
                                            href="/task/detail?id={{ task.id }}&type=task&user=admin" target="_blank">{{ task.id }}</a>&nbsp;&nbsp;
                                    </label>
                                {% empty %}
                                    无
                                {% endfor %}
                        </div>
                        {% else %}
                            <div class="form-group" style="display: flex; flex-wrap: wrap; justify-content: start;">
                            <input type="hidden" name="cid" value="{{ info.config_id }}">
                            <input type="hidden" name="checkUrl" value="{{ url }}">
                            <input type="hidden" name="isSearch" value="1">
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="漏采"> 漏采&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="标题错误"> 标题错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="时间错误"> 时间错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="作者错误"> 作者错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="来源错误"> 来源错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="频道错误"> 频道错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="频道url错误"> 频道url错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文错误"> 正文错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文xml样式错误"> 正文xml样式错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文图片url错误"> 正文图片url错误 &nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" class="minimal" value="正文图片url错误"> 其它 &nbsp;&nbsp;
                                <input id="orther" type="text" name="reasons" style="border: 0;border-bottom: 1px solid black;outline: medium;" v-model="msg">
                            </label>
                        </div>
                        {% endif %}
                        {% if searchTasks %}
                            <div class="form-group" style="display: flex; flex-wrap: wrap; justify-content: start;">
                            <input type="hidden" name="cid" value="{{ info.config_id }}">
                            <input type="hidden" name="checkUrl" value="{{ url }}">
                            <input type="hidden" name="isSearch" value="1">
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="漏采"> 漏采&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="标题错误"> 标题错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="时间错误"> 时间错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="作者错误"> 作者错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="来源错误"> 来源错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="频道错误"> 频道错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="频道url错误"> 频道url错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文错误"> 正文错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文xml样式错误"> 正文xml样式错误&nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" name="reasons" class="minimal" value="正文图片url错误"> 正文图片url错误 &nbsp;&nbsp;
                            </label>
                            <label>
                              <input type="checkbox" class="minimal" value="正文图片url错误"> 其它 &nbsp;&nbsp;
                                <input id="orther" type="text" name="reasons" style="border: 0;border-bottom: 1px solid black;outline: medium;" v-model="msg">
                            </label>
                        </div>
                        {% endif %}
                    </div>
                    <div class="col-md-4">
                        {% if info %}
                        <p style="display: flex; justify-content: space-between;">
                            <a href="/task/detail?id={{ info.task_id }}&type=task&user=admin" type="button" class="btn btn-block btn-primary" style="width: 49%; margin: 0;">任务详情</a>
                            <a href="task/{{ info.config_id }}/change/" type="button" class="btn btn-block btn-primary" style="width: 49%; margin: 0;">配置详情</a>
                        </p>
                        <button type="submit" class="btn btn-block btn-danger">判为不合格</button>
                        {% endif %}
                        {% if searchTasks %}
                        <button type="submit" class="btn btn-block btn-danger">判为不合格</button>
                        {% endif %}
                    </div>
                </form>
            </div>
            <div class="box-body">
                <div class="col-md-8">
                    <div class="box box-primary">
                        <div class="box-body">
                            <label class="control-label">原网页</label>
                            <div class="form-group">
                                <div id="iframe" class=" form-group has-success">
                                    <iframe class="iframe-detail" src="{{ url }}" width="100%" height="685px"
                                            scrolling="auto" frameborder="0"></iframe>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="box box-primary">
                        <div class="box-body">
                            <label class="control-label">查询内容</label>
                            <p style="clear: both"></p>
                            <div class="body-content" style="display: block; height: 750px; overflow:scroll; overflow-x:hidden;">
                                <div class="form-group has-success">
                                    <label class="control-label">标题&nbsp;&nbsp;</label>
                                    <p id="allsite_title" class="form-control" readonly="true" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" title="{{ info.title }}">{{ info.title }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label class="control-label">时间&nbsp;&nbsp;</label>
                                    <p id="allsite_ctime" class="form-control" readonly="true">{{ info.ctime }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label class="control-label">作者&nbsp;&nbsp;</label>
                                    <p id="allsite_source" class="form-control" readonly="true">{{ info.source }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label class="control-label">来源&nbsp;&nbsp;</label>
                                    <p id="retweeted_source" class="form-control" readonly="true">{{ info.retweeted_source }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label class="control-label">频道&nbsp;&nbsp;</label>
                                    <p id="allsite_channel" class="form-control" readonly="true">{{ info.siteName }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label class="control-label">频道URL&nbsp;&nbsp;</label>
                                    <p id="allsite_channel_url" class="form-control" readonly="true">{{ info.list_page_url }}</p>
                                </div>
                                <div class="form-group has-success">
                                    <label>内容&nbsp;&nbsp;</label>
                                    <div id="allsite_content" class="form-control" style="min-height:300px; max-height: 600px; overflow:scroll;" readonly="true">
                                        {{ info.content }}
                                    </div>
                                </div>
                                <div class="form-group has-success">
                                    <label>XML样式&nbsp;&nbsp;</label>
                                    <div id="allsite_content_xml" class="form-control" style="min-height:300px; max-height: 600px;" readonly="true">
                                        <iframe width="100%" height="100%" frameborder="0" srcdoc="{{ info.content_xml }}"></iframe>
                                    </div>
                                </div>
                                <div class="form-group has-success">
                                    <label>图片URL&nbsp;&nbsp;</label>
                                    <div id="allsite_pic_urls" class="form-control" style="min-height:300px; max-height: 600px;" readonly="true">
                                        <iframe width="100%" height="100%" frameborder="0" srcdoc="
                                        {% for i in info.pic_urls %}
                                        <img src='{{ i }}' alt=''>
                                        {% endfor %}
                                            "></iframe>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 自定义字段的展示，需要使用过滤器-->

{% endblock section_content %}

{% block jquery_js %}

{% endblock jquery_js %}

{% block body_tail %}
    <script src="{% static 'plugins/iCheck/icheck.min.js' %}"></script>
    <!-- page script -->
    <script>
         var obj = {},
        textInput = document.querySelector('#orther'),
        textSpan = document.querySelector('#orther');

        Object.defineProperty(obj, 'foo', {
          set: function (newValue) {
            textInput.value = newValue;
            textSpan.setAttribute('value',newValue);
          }
        });

        textInput.addEventListener('keyup', function (e) {
            obj.foo = e.target.value;
        });
        //iCheck for checkbox and radio inputs
        $('input[type="checkbox"].minimal').iCheck({
          checkboxClass: 'icheckbox_minimal-blue',
        });
        function getUrlParam(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r!=null) return unescape(r[2]); return null; //返回参数值
        }
    </script>

{% endblock body_tail %}
